<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News_cate extends Front_Controller {
 	var $siteSetings;
	var $announcement;
	var $lineclass; 
	var $des_tags;		//目的地标签   
	var $TicketClass;
	var $tagsclass;
	function __construct()
	{
		parent::__construct();
		$this->load->helper(array('form'));
		$this->load->model('front/Frontget_ml');
		$this->load->model('front/Search_m');
		$this->load->model('front/Car_cate_m');
		$this->load->model('front/News_cate_m');		
		$this->siteSetings=$this->Frontget_ml->get_site_settings();	//获取站点设置
		$this->announcement=$this->Frontget_ml->get_announcement();	//获取网站公告
		$this->lineclass=$this->Frontget_ml->get_lineclass();//获取线路分类
		$this->TicketClass=$this->Frontget_ml->getTicketClass();//获取汽车分类
		$this->newsclass=$this->Frontget_ml->get_newsclass();//获取资讯分类
		$this->tagsclass=$this->Frontget_ml->get_tagsclass();//获取攻略分类
		$this->des_tags=$this->Search_m->get_des_tags();	//获取网站标签
		$this->friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
		$this->model=8;			//温泉资讯model为8
	}
	public  function index(){	//温情资讯页
				$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
				$RecommendList=$this->News_cate_m->getRecommendList();//获取推荐资讯
				$TopNewsList=$this->News_cate_m->getTopNewsList();//获取最新资讯
				$TopPicList=$this->News_cate_m->getTopPicList();//获取最新图片资讯
				$NewsClassList=$this->News_cate_m->getNewsClassList($this->newsclass);//获取资讯分类列表
				$current_title="温泉资讯";
				$data=array("NewsClassList"=>$NewsClassList,"TopPicList"=>$TopPicList,"TopNewsList"=>$TopNewsList,"RecommendList"=>$RecommendList,"current_title"=>$current_title,"tagsclass"=>$this->tagsclass,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
				$this->load->view('inc/header',$data);
				$this->load->view('newsclass_v');	
	}
	public  function cate($cateid){	//站点新闻分类页
		if((int)$cateid){
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
		//	$commend_cars=$this->Car_cate_m->get_commend_cars($cateid);//获取推荐线路列表
			//分页
			$this->load->library('pagination');
			$config['base_url'] = site_url('/news_cate/cate/'.$cateid.'/');
				
			$total_rows= $this->News_cate_m->get_art_num($cateid);//获取查询条件下的记录总数
				$config['total_rows'] =$total_rows;
							// print_r($total_rows);
				$config['per_page'] = 10;
				$config['uri_segment'] = 4;
				$config['full_tag_open'] = '';
				$config['full_tag_close'] = '';
				$config['cur_tag_open']= '&nbsp;<span class="current">';
				$config['cur_tag_close']= '</span>';
				$config['prev_link']= '上一页';
				$config['next_link']= '下一页';
				$config['first_link']= ' 首页';
				$config['last_link']= ' 尾页';
				//	$config['use_page_numbers'] = TRUE;
				$this->pagination->initialize($config);
				$begin_record=$this->uri->segment(4);
				//分页end
				$subclass_list=$this->News_cate_m->get_subclass_list($cateid,$begin_record,$config['per_page']);//获取分类线路列表
				$TopNewsList=$this->News_cate_m->getTopNewsList();//获取最新资讯
				$current_title=$this->newsclass["classname"][$cateid];
				$data=array("TopNewsList"=>$TopNewsList,"current_title"=>$current_title,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"tagsclass"=>$this->tagsclass,"cateid"=>$cateid,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"cateid"=>$cateid,"subclass_list"=>$subclass_list,"announcement"=>$this->announcement,"friend_links"=>$friend_links);
				$this->load->view('inc/header',$data);
				$this->load->view('sub_newsclass_v');

	
		}else{
			redirect(base_url());	//参数错误
		}
	}	
	public  function show($carId){	//获取指定id文章信息
		if((int)$carId){
			$friend_links=$this->Frontget_ml->get_friend_links();//获取友情链接
			$newsInfo=$this->News_cate_m->get_newsInfo($carId);	//获取指定id文章信息
			if($newsInfo){
				$cateid=explode("-",str_replace(",","",$newsInfo[0]->news_class));//文章类id
				//	print_r($cateid);
				//	print_r($lineInfo);
				$TopNewsList=$this->News_cate_m->getTopNewsList();//获取最新资讯
				$current_title=$newsInfo[0]->news_title;
				$data = array("TopNewsList"=>$TopNewsList,"model"=>$this->model,"current_title"=>$current_title,"tagsclass"=>$this->tagsclass,"newsclass"=>$this->newsclass,"TicketClass"=>$this->TicketClass,"id"=>$carId,"des_tags"=>$this->des_tags,"siteSetings"=>$this->siteSetings,"lineclass"=>$this->lineclass,"newsInfo"=>$newsInfo,"cateid"=>$cateid[0],"announcement"=>$this->announcement,"friend_links"=>$friend_links);
				$this->load->view('inc/header',$data);
				$this->load->view('news_show_v');
			}else{
				redirect(base_url());	//无改文章
				
			}
		}else{
			redirect(base_url());	//参数错误
		}
	}	

}